package com.glodon.paas.monitor.server.biz.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.glodon.paas.monitor.server.biz.domain.MonitorCollectorEntity;
import com.glodon.paas.monitor.server.biz.mapper.MonitorCollectorMapper;
import com.glodon.paas.monitor.server.biz.service.MonitorCollectorService;
import com.glodon.paas.monitor.server.exception.MonitorException;

@Service("monitorCollectorService")
public class MonitorCollectorServiceImpl implements MonitorCollectorService {

	@Autowired
	private MonitorCollectorMapper	monitorCollectorMapper;

	@Override
	public int deleteByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"deleteByPrimaryKey collector id is null!");
		}
		return monitorCollectorMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(MonitorCollectorEntity record) {
		if (null == record || null == record.getAppId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID, "insert collector record is null!");
		}
		return monitorCollectorMapper.insert(record);
	}

	@Override
	public int insertSelective(MonitorCollectorEntity record) {
		if (null == record || null == record.getAppId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"insertSelective collector record is null!");
		}
		return monitorCollectorMapper.insertSelective(record);
	}

	@Override
	public MonitorCollectorEntity selectByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"selectByPrimaryKey collector id is null!");
		}
		return monitorCollectorMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(MonitorCollectorEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKeySelective collector record is null!");
		}
		return monitorCollectorMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(MonitorCollectorEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKey collector record is null!");
		}
		return monitorCollectorMapper.updateByPrimaryKey(record);
	}

}
